package fr.laposte.erreurcaisse.DAO;

import java.sql.Connection;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanHandler;

import fr.laposte.erreurcaisse.beans.Authentification;
import fr.laposte.erreurcaisse.beans.I_Bean;
import fr.laposte.erreurcaisse.controlers.DataSourceHelper;
import fr.laposte.erreurcaisse.controlers.PropertiesManager;

public class DAO_Authentification implements DAO_Interface
{
	Authentification au = null;
	public DAO_Authentification(I_Bean bi)
	{
		au = (Authentification) bi;
	}
	
	@Override
	public void add()
	{
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void update()
	{
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void delete()
	{
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public I_Bean find()
	{
		try
		{
			PropertiesManager p = PropertiesManager.getInstance();
			Connection c = DataSourceHelper.getInstance().getConnection();
			QueryRunner qr = new QueryRunner();
			ResultSetHandler<Authentification> rsh = new BeanHandler<>(Authentification.class);
			Authentification a = qr.query(c, p.getSQLSelect(), rsh, au.getAgentCode());
			return a;
		}
		catch (Exception e)
		{
			System.err.println(e);
		}
		return null;
	}
	
	@Override
	public List<I_Bean> findAll()
	{
		// TODO Auto-generated method stub
		return null;
	}
	
}
